<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="org.apache.commons.beanutils.locale.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet"  href="<%=request.getContextPath()%>/css/display.css" type="text/css" media="screen" />
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/form.js"></script>
<title>Gestione Auser - Piano dei conti</title>
</head>
<body>
	 <jsp:useBean id="editPconti" scope="session" class="auser.PianoDeiConti" />	 		 
	 <form method="post" action="save.jsp">
		 <c:if test="${empty param.id}" >
		 	<h1>Aggiunta di una voce al piano dei conti</h1> 
		 </c:if>
		 
		 <c:if test="${!empty param.id}" >
		 	<h1>Voce del piano dei conti</h1> 
		 </c:if>
		 
		<fieldset>
			<legend>Dati principali </legend>
			
		 
	 		<label for='descrizione'>Descrizione</label><input type="text" name="descrizione" id="descrizione" size="45" value="${editPconti.descrizione}" /> 
	 		<label class='validError'>${eDescrizione}</label><br/>
	 		 
	 		<label for='l1'>Livello 1</label><input type="text" name="l1" id="l1" size="45" value="${editPconti.l1}" /> 
	 		<label class='validError'>${eL1}</label><br/>
	 		
	 		<label for='l2'>Livello 2</label><input type="text" name="l2" id="l2" size="45" value="${editPconti.l2}" /> 
	 		<label class='validError'>${eL2}</label><br/>
	 		
	 		<label for='l3'>Livello 3</label><input type="text" name="l3" id="l3" size="45" value="${editPconti.l3}" /> 
	 		<label class='validError'>${eL3}</label><br/>
	 		
	 		<label for='l4'>Livello 4</label><input type="text" name="l4" id="l4" size="45" value="${editPconti.l4}" /> 
	 		<label class='validError'>${eL4}</label><br/>
			
			<label for='tipo'>Tipo</label>
			<select name="tipo" id="tipo"   value="${editPconti.tipo}" >
				<option value="Dare" ${editPconti.tipo=="Dare"? "selected":""}>Dare</option>
				<option value="Avere"  ${editPconti.tipo=="Avere"? "selected":""}>Avere</option>
			</select><br>
			
			<% facades.SessionFacade sfacade = facades.SessionFacade.getInstance(request) ; %>
			<label for='tipo'>Circolo</label>
			  
			<select name="circoloid" id="circoloid"   >
				<c:forEach items="${sfacade.circoli}" var="circolo" varStatus="st">
					<option value="<%=sfacade.getID("circolo",pageContext) %>"  ${editPconti.circolo.codice==circolo.codice?"selected":""} >
						${circolo.descrizione} - ${circolo.indirizzo}
					</option>	
				</c:forEach>
			</select>
			 
	 		<label class='validError'>${eL4}</label><br/>
	 		<div class='howtomsg validError'>${mainError}</div>
	 		<br/>
	 		
	 		<input class='button' type='submit' value='Salva' id='btnSave' /> 
			<input class='button' type='button' value='Chiudi' id='btnClose' onclick='document.location="<%=request.getContextPath()%>/app/start/index.jsp"'>
	 	</fieldset>
	 </form>

</body>
</html>